package com.estate.utils.json;

import java.util.List;

public class JSONConverter {
	public static String convertFromJSONItems(List<JSONItem> items){
		if(items==null){
			return "";
		}
		if(items.size()==0){
			return "{'results':0,'elements':[]}";
		}
		StringBuilder sb=new StringBuilder();
		sb.append("{'results':"+items.size()+",'elements':");		    
		sb.append("[");
		int last=items.size()-1;
		for(int i=0;i<last;i++){
			sb.append(items.get(i).toJSON()+",");
		}
		sb.append(items.get(last).toJSON()+"]}");
		return sb.toString();
	}
	public static String convertFormJSONItem(JSONItem item){
		return item.toJSON();
	}
}
